package com.second_kill.second_kill_app.controller;

import com.second_kill.second_kill_app.service.SecondKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by fangjicai on 2020/4/29.
 */

@RestController
public class SecondKillController {
    @Autowired
    private SecondKillService secondKillService;
    //秒杀商品id以666，库存量为50为测试
    //@GetMapping("/secondKill/{userId}/{shopId}/{random}")
    @GetMapping("/secondKill/{userId}/{shopId}")
    //random在秒杀开始的那一刻动态触发生成并保存在redis中，通过拦截器拦截秒杀url地址，是否包含该随机数，不包含则不予处理
    public boolean secondKill(@PathVariable("userId") String userId,@PathVariable("shopId") String shopId){
        boolean flag = this.secondKillService.secondKill(userId, shopId);
        return flag;
    }
}
